package com.mofang.activity.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.RelativeLayout;

import com.mofang.R;
import com.mofang.activity.BaseTitleViewActiviey;
import com.mofang.adapters.CommissionSubsidiaryAdapter;

public class MyCommissionDetailActivity extends BaseTitleViewActiviey {
	private RelativeLayout none_data;
    ListView list_commission_subsidiary;
    List<Map<String, Object>> list;
    CommissionSubsidiaryAdapter adapter;
    String dataName[]={"张三","张三","张三","张三","张三","张三"};
    String dataPhone[]={"13771567784","13771567784","13771567784",
    		"13771567784","13771567784","13771567784"};
    String dataDate[]={"2014-04-25","2014-04-25","2014-04-25",
    		"2014-04-25","2014-04-25","2014-04-25"};
    String dataCommission[]={"Y 1280","Y 1280","Y 1280",
    		"Y 1280","Y 1280","Y 1280"};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_my_commission_detail);
		super.onCreate(savedInstanceState);
		setNavigationTitle("佣金明细");
		setNavigationLeftBtnImage(R.drawable.return_arrow);

	}

	@Override
	protected void initView() {
		super.initView();
		none_data = (RelativeLayout) findViewById(R.id.none_data);
		list_commission_subsidiary = (ListView) findViewById(R.id.list_commission_subsidiary);
		addData();
		// 判断有没有数据，无数据则隐藏ListView,并显示无数据页面
		if (list.size() > 0) {
			adapter = new CommissionSubsidiaryAdapter(
					MyCommissionDetailActivity.this, list);
			list_commission_subsidiary.setAdapter(adapter);
		} else {
			list_commission_subsidiary.setVisibility(View.GONE);
			none_data.setVisibility(View.VISIBLE);
		}

	}

	private void addData() {
		// TODO Auto-generated method stub
		list = new ArrayList<Map<String, Object>>();
		for (int i = 0; i < dataName.length; i++) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("name", dataName[i]);
			map.put("phone", dataPhone[i]);
			map.put("commission", dataCommission[i]);
			map.put("date", dataDate[i]);
			list.add(map);
		}
	}
}